<template>
  <div>
    <h2>添加新书</h2>
    <form @submit.prevent="addBook">
      <input v-model="book.title" placeholder="书名" required>
      <input v-model="book.author" placeholder="作者" required>
      <input v-model="book.isbn" placeholder="ISBN" required>
      <button type="submit">添加</button>
    </form>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  data() {
    return {
      book: {
        title: '',
        author: '',
        isbn: ''
      }
    }
  },
  methods: {
    async addBook() {
      await axios.post('/api/books', this.book);
      this.book = { title: '', author: '', isbn: '' };
      // 可能需要刷新图书列表
    }
  }
}
</script>